fix: reject non-unary lambdas at closure creation (JVM FuncValue.eval)#899
Open
mwaddip wants to merge 1 commit into
Open
fix: reject non-unary lambdas at closure creation (JVM FuncValue.eval)#899mwaddip wants to merge 1 commit into
mwaddip wants to merge 1 commit into
Conversation
The JVM supports only unary functions at eval: FuncValue.eval (values.scala:1042-1056) builds its closure iff args.length == 1 and otherwise throws "Function must have 1 argument" — at closure CREATION, so a bound-but-never-applied non-unary lambda rejects too (BlockValue evaluates ValDefs eagerly). Apply.eval (values.scala:1236-1244) gates application arity the same way, which sigma-rust already matches. sigma-rust created the Lambda value for any arity and evaluated non-unary lambdas to completion. Both serializers are arity-agnostic (FuncValueSerializer reads a numArgs VLQ), so such trees are reachable from real wire bytes — an over-accept / chain-split divergence: a tree carrying a 2-arg (or 0-arg) lambda validates on sigma-rust and fails on the JVM. Gate Value::Lambda creation (the single construction site) on args.len() == 1. The reject is eval-time, NOT parse-time: a non-unary lambda on the dead branch of a lazy `if` still accepts (pinned by the vector twin). Tests drive the four SANTA FuncValue.non_unary_arity vector byte trees end-to-end (parse → proposition → eval): 2-arg applied, 2-arg bound, 0-arg applied each reject; the lazy-if twin accepts Int 5. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The JVM supports only unary functions at eval: FuncValue.eval (values.scala:1042-1056) builds its closure iff args.length == 1 and otherwise throws "Function must have 1 argument" — at closure creation, so a bound-but-never-applied non-unary lambda rejects too (BlockValue evaluates ValDefs eagerly). Apply.eval gates application arity the same way, which sigma-rust already matches.
sigma-rust evaluated non-unary lambdas to completion. Both serializers are arity-agnostic, so such trees are reachable from wire bytes — an accept/reject consensus divergence.
Gates Value::Lambda creation (the single construction site) on args.len() == 1. Eval-time only: a non-unary lambda on the dead branch of a lazy
ifstill accepts. Tests drive the four JVM-blessed vector byte trees end-to-end.